{template 'common/header'}
{if $operation == 'display'}
<a href="{php echo $this->createWebUrl('teacher',array('op' =>'post'))}" class="btn btn-success"><i class="fa fa-plus"></i> 添加教师</a>
<div class="panel panel-info" style="margin-top: 10px;">
	<div class="panel-heading">搜索</div>
	<div class="panel-body">
		<form action="./index.php" method="get" class="form-horizontal" role="form" id="form1">
			<input type="hidden" name="c" value="site" />
			<input type="hidden" name="a" value="entry" />
			<input type="hidden" name="m" value="hellozjx_mapwxapp" />
			<input type="hidden" name="do" value="teacher" />
			<div class="form-group">
				<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">关键字</label>
				<div class="col-sm-8 col-lg-9 col-xs-12">
					<input class="form-control" name="keyword" id="" type="text" value="{$_GPC['keyword']}" placeholder="输入教师名称">
				</div>
			</div>
			<div class="form-group">
				<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label"></label>
				<div class="col-sm-5 col-xs-12">
					<button class="btn btn-success"><i class="fa fa-search"></i> 搜索</button>
				</div>
			</div>
		</form>
	</div>
</div>
<div class="main panel panel-default">
	<div class="panel-body table-responsive">
		<table class="table table-hover">
			<thead class="navbar-inner">
				<tr>
					<th style="width:30px;">ID</th>
					<th style="text-align: center;">显示顺序</th>					
					<th style="text-align: center;">教师名称</th>
					<th style="text-align: center;">头像</th>
					<th style="text-align: center">教龄</th>
					<th style="text-align: center">性别</th>
					<th style="text-align: center">所在城市</th>
					<th style="text-align: center">余额</th>
					<th style="text-align: center">状态</th>
					<th style="text-align: center;">操作</th>
				</tr>
			</thead>
			<tbody>
				{loop $list $item}
				<tr>
					<td style="vertical-align: inherit;">{$item['id']}</td>
					<td style="text-align: center;vertical-align: inherit;">{$item['sort']}</td>
					<td style="text-align: center;vertical-align: inherit;">{$item['name']}</td>
					<td style="text-align: center;vertical-align: inherit;"><img width="100" src="{php echo tomedia($item['avatar'])}" alt=" "></td>
					<td style="text-align: center;vertical-align: inherit;">{$item['teach_age']}</td>
					<td style="text-align: center;vertical-align: inherit;">{if $item['sex']==0}男{elseif $item['sex']==1}女{else}保密{/if}</td>
					<td style="text-align: center;vertical-align: inherit;">{$item['city']}</td>
					<td style="text-align: center;vertical-align: inherit;">{if empty($item['money'])}0.00{else}{$item['money']}{/if}</td>
					<td style="text-align: center;vertical-align: inherit;">{if $item['status'] == 1}已启用{else}已禁用{/if}</td>
					<td style="text-align:center;font-size: 10px;vertical-align: inherit;">
						<a href="{php echo $this->createWebUrl('teacher', array('op' => 'post', 'id' => $item['id']))}" class="btn btn-default btn-sm" data-toggle="tooltip" data-placement="top" title="修改"><i class="fa fa-edit"></i></a>
						<a href="{php echo $this->createWebUrl('teacher', array('op' => 'delete', 'id' => $item['id']))}" onclick="return confirm('确认删除吗？');return false;" class="btn btn-default btn-sm" data-toggle="tooltip" data-placement="top" title="删除"><i class="fa fa-times"></i></a>
					</td>
				</tr>
				{/loop}
			</tbody>
		</table>
		{$pager}
	</div>
</div>
{elseif $operation == 'post'}
<div class="main">
	<form action="" method="post" class="form-horizontal form" enctype="multipart/form-data" onsubmit='return formcheck()'>
		<div class="panel panel-default">
			<div class="panel-heading">
				教师信息
			</div>
			<div class="panel-body">
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">排序</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" name="sort" class="form-control" value="{$teacher['sort']}" />
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label"><span style="color:red">*</span>是否显示</label>
					<div class="col-sm-9 col-xs-12">
						<label class='radio-inline'>
							<input type='radio' name='status' value='1' {if empty($teacher['status']) || $teacher['status']==1}checked{/if} /> 是
						</label>
						<label class='radio-inline'>
							<input type='radio' name='status' value='2' {if $teacher['status']==2}checked{/if} /> 否
						</label>
					</div>
				</div>
				{if !empty($subject)}
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label"><span style="color:red">*</span>课程</label>
					<div class="col-sm-9 col-xs-12">
						{loop $subject $index $item}
							<label class="checkbox-inline">
								<input name="subject[]" type="checkbox" {if !empty($cates) && in_array($item['id'],$cates[2])}checked{/if} value="{$item['id']}" /> {$item['name']}
							</label>
						{/loop}
					</div>
				</div>
				{/if}
				{if !empty($class)}
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label"><span style="color:red">*</span>课堂</label>
					<div class="col-sm-9 col-xs-12">
						{loop $class $index $item}
						<label class="checkbox-inline">
							<input name="class[]" type="checkbox" {if !empty($cates) && in_array($item['id'],$cates[1])}checked{/if} value="{$item['id']}"/> {$item['name']}
						</label>
						{/loop}
					</div>
				</div>
				{/if}
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label"><span style="color:red">*</span>教师姓名</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" id='name' name="name" class="form-control" value="{$teacher['name']}" />
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label"><span style="color:red">*</span>教师性别</label>
					<div class="col-sm-9 col-xs-12">
						<label class='radio-inline'>
							<input type='radio' name='sex' value='0' {if $teacher['sex']==0}checked{/if} /> 男
						</label>
						<label class='radio-inline'>
							<input type='radio' name='sex' value='1' {if $teacher['sex']==1}checked{/if} /> 女
						</label>
						<label class='radio-inline'>
							<input type='radio' name='sex' value='2' {if $teacher['sex']==2}checked{/if} /> 保密
						</label>
					</div>
				</div>
				<div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">教师头像</label>
                    <div class="col-sm-9 col-xs-12">
                        {php echo tpl_form_field_image('avatar', $teacher['avatar'])}
						<span class="help-block">图片推荐大小：250px * 200px</span>
                    </div>
                </div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label"><span style="color:red">*</span>教龄</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" id='teach_age' name="teach_age" class="form-control" value="{$teacher['teach_age']}" />
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label"><span style="color:red">*</span>年龄</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" id='age' name="age" class="form-control" value="{$teacher['age']}" />
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label"><span style="color:red">*</span>电话</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" id='phone' name="phone" class="form-control" value="{$teacher['phone']}" />
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label"><span style="color:red">*</span>邮箱</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" id='email' name="email" class="form-control" value="{$teacher['email']}" />
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label"><span style="color:red">*</span>身份证号</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" id='idcard' name="idcard" class="form-control" value="{$teacher['id_card']}" />
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label"><span style="color:red">*</span>城市</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" id='city' name="city" class="form-control" value="{$teacher['city']}" />
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label"><span style="color:red">*</span>详细地址</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" id='address' name="address" class="form-control" value="{$teacher['address']}" />
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label"><span style="color:red">*</span>所在位置</label>
					<div class="col-sm-9 col-xs-12">
						{php echo tpl_form_field_coordinate('location', array('lng' => $teacher['longitude'], 'lat' => $teacher['latitude']))}
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">教师详情</label>
					<div class="col-sm-9 col-xs-12">
						{php echo tpl_form_field_image('detail', $teacher['detail'])}
						<span class="help-block">图片推荐大小：250px * 200px</span>
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">有无资格证书</label>
					<div class="col-sm-9 col-xs-12">
						<label class='radio-inline'>
							<input type='radio' name='qualification' value='0' {if $teacher['qualification']==0}checked{/if} /> 无
						</label>
						<label class='radio-inline'>
							<input type='radio' name='qualification' value='1' {if $teacher['qualification']==1}checked{/if} /> 有
						</label>
					</div>
				</div>
            </div>
		</div>
		<div class="form-group col-sm-12">
			<input type="submit" name="submit" value="提交" class="btn btn-primary col-lg-1" />
			<input type="hidden" name="id" value="{$teacher['id']}" />
			<input type="hidden" name="token" value="{$_W['token']}" />
		</div>
	</form>
</div>
<script language='javascript'>
	function formcheck() {
		if ($("#name").val() == '') {
			util.message("请输入名称");
			return false;
		}
		if ($("#address").val() == '') {
			util.message("请填写地址");
			return false;
		}
		if($('#phone').val()==''){
			util.message('请输入手机号');
			return false;
		}
		if($('#idcard').val()==''){
			util.message('请输入身份证号');
			return false;
		}
		var class_array=new Array();
		$('input[name="class[]"]:checked').each(function(){
			class_array.push($(this).val());//向数组中添加元素
		});
		if(class_array.length == 0){
			util.message('请选择课堂');
			return false;
		}
		var subject_array=new Array();
		$('input[name="subject[]"]:checked').each(function(){
			subject_array.push($(this).val());//向数组中添加元素
		});
		if(subject_array.length == 0){
			util.message('请选择课程');
			return false;
		}
		return true;
	}
</script>
{/if}

{template 'common/footer'}